
// Defines the root of the object model. This is not exposed as a COM object.

#ifndef LONGKEY_PCAGENT_MODEL_H_
#define LONGKEY_PCAGENT_MODEL_H_

#include "../base/synchronized.h"

// #ifndef _ATL_FREE_THREADED
// #error Must use _ATL_FREE_THREADED to avoid differences in member offsets.
// #endif

class WorkerModeInterface;

class Model
{
public:
	explicit Model(WorkerModeInterface* worker);
	virtual ~Model();

	const Lockable& lock() const { return lock_; }

	// Returns true if the model lock is held by the calling thread.
	bool IsLockedByCaller() const { return ::GetCurrentThreadId() == lock_.GetOwner(); }

private:
	LLock lock_;

	WorkerModeInterface* worker_;

	DISALLOW_EVIL_CONSTRUCTORS(Model);
};

#endif	// LONGKEY_PCAGENT_MODEL_H_